import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Field, reduxForm } from 'redux-form';
import { FormattedMessage, injectIntl } from 'react-intl';
import { TextField, Row, Col, Button, Select, ButtonGroup } from '@folio/stripes/components';
import {  IfPermission } from '@folio/stripes/core';
import DatePerfectChoice from '../../util/DateCustomize/DatePerfectChoice';
class SearchForm extends Component {
    static propTypes = {
      handleSubmit: PropTypes.func.isRequired,
      initialValues: PropTypes.object,
      dictionary: PropTypes.object,
      cleanSearch: PropTypes.func,
      intl: PropTypes.func,
      add:PropTypes.func
    };

    fieldChange = () => {
      const { handleSubmit } = this.props;
      this.setState(() => {
        handleSubmit();
      });
    };

    render() {
      const {
        handleSubmit,
        add,
          intl,
          toModel
      } = this.props;

      return (

        <form data-test-form-page id="form-search" onSubmit={handleSubmit}>
          <Row style={{ width: '100%' }}>
            <Col xs={2}>
              <Field
                component={TextField}
                name="username"
                placeholder={intl.formatMessage({ id: 'ui-party.loans.columns.readerName' })}
                autoComplete={'off'}
              />
            </Col>
            <Col xs={2}>
              <Field
                component={TextField}
                name="barcode"
                placeholder={intl.formatMessage({ id: 'ui-party.loans.columns.readerAccount' })}
                autoComplete={'off'}
              />
            </Col>
        
           {/* <Col xs={2}>
           <Field
               placeholder={intl.formatMessage({ id: 'ui-party.loans.columns.party.blocklist.stopday' })}
               name="prisonTerm"
               component={DatePerfectChoice}
               dateFormat="YYYY-MM-DD"
               isClear
               timeZone="Asia/Shanghai"
       
           />
                    
           </Col> */}
           <Col xs={2}>
           <Field
               placeholder={intl.formatMessage({ id: 'ui-party.createDate' })}
               name="createDate"
               component={DatePerfectChoice}
               dateFormat="YYYY-MM-DD"
               isClear
               timeZone="Asia/Shanghai"
       
           />
                    
           </Col>
            <Col xs={3}>
              <ButtonGroup>
                <Button type="submit">
                  <FormattedMessage id="ui-party.search" />
                </Button>
                  <IfPermission perm={"ui-party.auxiliary.manage.view.add"}>
                      <Button onClick={() => {  toModel('/black/list/add') }}>
                          <FormattedMessage
                              id="ui-party.add"
                          />
                      </Button>
                  </IfPermission>
             </ButtonGroup>
            </Col>
          </Row>
        </form>

      );
    }
}

export default injectIntl(
  reduxForm({
    form: 'blackListSearchFrom' + new Date().getTime(),
    navigationCheck: true,
    enableReinitialize: true
  })(SearchForm)
);
